<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .hz{
            width: 300px;
            height: 200px;
            background-color: aqua;
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            margin: auto;
            display: none;
        }
        th,td{
            width: 200px;
            height: 50px;
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <button onclick="cx()">添加</button>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
            </tr>
        </thead>
        <tbody>
    
        </tbody>
    </table>
    <div class="hz">
        姓名：<input type="text" class="name"><br>
        性别：<input type="text" class="sex"><br>
        年龄：<input type="text" class="age"><br>
        <button onclick="tj()" >确定</button><button onclick="qx()">取消</button>
    </div>
   
</body>
</html>
<script>
    var hz=document.querySelector(".hz")
    var tb=document.querySelector("tbody")
    var name=document.querySelector(".name")
    var sex=document.querySelector(".sex")
    var age=document.querySelector(".age")
    function cx(){
        hz.style.display='block'
    }
    function qx(){
        hz.style.display='none'
    }
    function tj(){
        var tr=document.createElement('tr')
        tr.innerHTML=`
            <td>${name.value}</td>
            <td>${sex.value}</td>
            <td>${age.value}</td>
        `;
        tb.appendChild(tr)
    }
</script>